package com.building.hcrm.common;

import java.io.Serializable;
import java.util.Date;

import com.building.hcrm.common.ComFunc;
import com.building.hcrm.model.SysUser;
import com.building.hcrm.model.SysUserParam;
import com.building.hcrm.wcf.UserServiceProxy;

import android.content.Context;
import android.util.Log;

@SuppressWarnings("serial")
public class User extends SysUser
{
	private Boolean IsLogin = false;
	
	private Context _context;
	
	private static User _instance ;

	public static User getInstance(Context context)
	{
		if(null == _instance)
			_instance = new User();
		_instance._context = context;
		return _instance;
	}
	
	public void Login(String strId, String strPwd)
	{
		SysUserParam param = new SysUserParam();
		param.userNum=strId;
		param.userPwd=strPwd;
		try
		{
			_instance = UserServiceProxy.getInstance(_context).UserValidInfo(param);
			_instance._context =_context;
			_instance.IsLogin = true;
		}
		catch (Exception e)
		{
			Log.e(this.toString(),ComFunc.getExceptionMessage(e),e);
		}
	}
	
	public void Logout()
	{
		DepartID=null; 
		DepartName=null;
		JobID=null;    
		JobName=null;  
		UserBirth=null;  
		UserCall=null; 
		UserCome=null;   
		UserEdu=null;  
		UserGender=null;
		UserMail=null; 
		UserName=null; 
		UserNum=null;  
		UserOff=null;    
		UserOrigrn=null;
		UserPhone=null;
		UserPwd=null;  
		UserState=null;
		IsLogin = false;
	}

	public Boolean getIsLogin()
	{
		return IsLogin;
	}
}
